'use strict';

exports.create = async ctx => {
  console.log('asdasdasd')
  ctx.validate({
    title: {
      type: 'string',
      min: 1,
      max: 40,
    },
    link: {
      type: 'url',
    },
  });
  ctx.sendSuccess(await ctx.service.homelinks.create());
};

exports.destroy = async ctx => {
  ctx.validate({
    id: {
      type: 'mongo-id',
    },
  }, ctx.params);
  ctx.sendSuccess(await ctx.service.homelinks.destroy());
};

exports.update = async ctx => {
  ctx.validate({
    title: {
      type: 'string',
      min: 1,
      max: 40,
    },
    link: {
      type: 'url',
    },
  });
  ctx.validate({
    id: {
      type: 'mongo-id',
    },
  }, ctx.params);
  ctx.sendSuccess(await ctx.service.homelinks.update());
};
